package com.dcbeida.model;

import com.dcbeida.MyApplication;
import com.dcbeida.utils.GenApiHashUrl;
import com.dcbeida.utils.JsonGet;

import dc.medicine.com.okhttplib.OkHttpUtils;
import dc.medicine.com.okhttplib.callback.AbsCallback;

/**
 * Sean
 */
public class MsgModel {

    private static MsgModel mModel;

    private MsgModel() {

    }

    public static MsgModel newInstance() {
        if (mModel == null) {
            return new MsgModel();
        } else {
            return mModel;
        }
    }

    public void getList(int pageindex, int pagesize, AbsCallback mAbsCallback) {
        JsonGet jg = new JsonGet().putopt("uid", MyApplication.user.getUid())
                .putopt("shopid",MyApplication.user.getShopid())
                .putopt("pageindex",pageindex)
                .putopt("pagesize",pagesize);
        String json = jg.tostring();

        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "getNotifyList")
                .paramsApp("params", json).execute(mAbsCallback);
    }


    public void getDetail(int messageId, AbsCallback mAbsCallback) {
        JsonGet jg = new JsonGet().putopt("uid", MyApplication.user.getUid())
                .putopt("shopid",MyApplication.user.getShopid())
                .putopt("messageid",messageId);

        String json = jg.tostring();

        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "getNotifyDetail")
                .paramsApp("params", json).execute(mAbsCallback);
    }
    public void addNotifyFeedback(int messageId,String msg, AbsCallback mAbsCallback) {
        JsonGet jg = new JsonGet().putopt("uid", MyApplication.user.getUid())
                .putopt("shopid",MyApplication.user.getShopid())
                .putopt("content",msg)
                .putopt("messageid",messageId);

        String json = jg.tostring();

        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "addNotifyFeedback")
                .paramsApp("params", json).execute(mAbsCallback);
    }


    public void getCancel() {
        OkHttpUtils.getInstance().cancelTag(this);
    }
}
